<template>
	<view class="">
		<!--  -->
		<ben></ben>
		<!--  -->
		<view class="head_back posabs zin-1 wth100" style="top: 0;" :style="{ paddingTop: topHight + 'px'}">
		</view>
		<view class="pad20 background_f rad2 text_center col3 font500" style="margin: 0 70rpx;"
			:style="{ marginTop: topHight + 'px'}">
			<image :src="userinfo.stores_logo" class="rad2" style="width: 100rpx;height: 100rpx;"></image>
			<view class="size30 font600 mintop30">
				{{ userinfo.stores_name }}
			</view>
			<view class="size26 mintop10">
				地址：{{ userinfo.stores_address }}
			</view>
			<view class="mintop20 row size24 just_cont_c" style="color: #FE9110;"
				@click="$jump.nav('/indexpackage/store/store_info')">
				编辑信息
				<u-icon name="arrow-right" color="#FE9110" size="11"></u-icon>
			</view>
		</view>
		<view class="min30 col3 size30 font600">
			营业数据
		</view>
		<view class="min30_rl background_f rad2" style="padding: 6rpx;">
			<view class="pad20 box row padtop40">
				<view class="flex1 text_center size26" style="color: #AF5E2F;">
					本月订单数
					<view class="size34 font600 mintop10" style="color: #802E0B;">
						{{ reven.current_month_orders }}
					</view>
				</view>
				<view class="flex1 text_center size26" style="color: #AF5E2F;">
					本月营业额
					<view class="size34 font600 mintop10" style="color: #802E0B;">
						{{ reven.current_month_revenue }}
					</view>
					<view class="size24 row align_item_c just_cont_c mintop10"
						@click="$jump.nav('/indexpackage/store/turnover_detail')">
						明细
						<u-icon name="arrow-right" color="#AF5E2F" size="11"></u-icon>
					</view>
				</view>
				<!-- <view class="flex1 text_center size26" style="color: #AF5E2F;">
					本月积分
					<view class="size34 font600 mintop10" style="color: #802E0B;">
						6666
					</view>
					<view class="size24 row align_item_c just_cont_c mintop10" @click="$jump.nav('/indexpackage/store/integral_detail')">
						明细
						<u-icon name="arrow-right" color="#AF5E2F" size="11"></u-icon>
					</view>
				</view> -->
			</view>
			<view class="column title font500 size24" style="margin: 10rpx 40rpx;">
				<!-- <view class="row flex1 " style="border-bottom: 2rpx solid #F0F0F0;">
					<view class="flex1 padtop20 padbottom30 padleft20" style="border-right: 2rpx solid #F0F0F0;">
						总余额
						<view class="size30 col24 mintop10">
							￥{{ '10000.00' }}
						</view>
					</view>
					<view class="flex1 padtop20 padbottom30 padleft20">
						已提现金额
						<view class="size30 col24 mintop10">
							￥{{ '6666.00' }}
						</view>
					</view>
				</view> -->
				<view class="row flex1">
					<view class="flex1 padtop20 padbottom30 padleft20" style="border-right: 2rpx solid #F0F0F0;">
						总积分
						<view class="size30 col24 mintop10">
							{{ userinfo.shop_money }}
						</view>
					</view>
					<view class="flex1 padtop20 padbottom30 padleft20">
						已提现积分
						<view class="size30 col24 mintop10">
							{{ reven.total_payouts }}
						</view>
					</view>
				</view>
			</view>
			<view class="min30_rl mintop10 row minbottom20">
				<view class="flex1">
					<u-button text="提现记录" shape="circle" customStyle="color: ##8E4624;" hairline="true" size="normal"
						@click="$jump.nav('/indexpackage/store/cashout_records')"></u-button>
				</view>
				<view class="flex1 minleft30">
					<u-button text="立即提现" shape="circle"
						color="linear-gradient( 63deg, #FF515E 0%, #FF7F3E 100%), linear-gradient( 167deg, #FF6B4A 0%, rgba(255,123,77,0) 100%)"
						hairline="false" size="normal" @click="$jump.nav('/indexpackage/store/cashout')"></u-button>
				</view>
			</view>
		</view>
		<!-- 底部tab -->
		<block>
			<storeTab :item="1"></storeTab>
		</block>
		<!-- 底部tab -->
	</view>
</template>

<script>
	import storeTab from "@/components/tabBar/storeTab.vue"
	export default {
		components: {
			storeTab
		},
		data() {
			return {
				topHight: '',
				user_id: '',
				userinfo: {},
				shop_img: 'https://cdn.uviewui.com/uview/album/3.jpg',
				title: '舟渔记海鲜',
				add: '云南省昆明市呈贡区XX街道XX号',
				reven: ''
				// baseList: [{

				// 		title: '蔬菜豆品',
				// 		image: '/static/image/Group 427319470.png',
				// 	},
				// 	{

				// 		title: '肉蛋禽',
				// 		image: '/static/image/Group 427319471.png',
				// 	},
				// 	{

				// 		title: '休闲零食',
				// 		image: '/static/image/Group 2.png',
				// 	},
				// 	{

				// 		title: '酒水饮料',
				// 		image: '/static/image/Group 427319472.png',
				// 	}
				// ],
			}
		},

		onLoad() {
			let app = uni.getSystemInfoSync()
			this.topHight = app.statusBarHeight + 42
			this.user_id = uni.getStorageSync('user_id');
		},
		onShow() {
			//当前页面展示的时候他就执行该生命周期
			const token = uni.getStorageSync('token');
			if (token) {
				//如果存在token
				this.getUserinfo()
				this.getRevenue()
				//按正常逻辑来讲 登录成功 我们是不是需要向服务器获取用户的信息？
				//那么我们一起来获取用户信息
			} else {

				uni.showToast({
					title: '您还未登录，正在前往登录',
					icon: 'none'
				})
				setTimeout(function() {
					uni.navigateTo({
						url: "/mypackage/user/login"
					})
				}, 1000)
			}
		},
		methods: {
			async getRevenue() {
				let {
					code,
					message,
					data
				} = await this.$com.fetchGet("shop/total_revenue/" + this.user_id)
				if (code == 200) {
					this.reven = data

				} else {
					console.log(message);
				}
			},
			async getUserinfo() {
				let {
					code,
					message,
					data
				} = await this.$com.fetchGet("member/user_info/" + this.user_id)
				if (code == 200) {
					this.userinfo = data

				} else {
					console.log(message);
				}
			}
		}
	}
</script>

<style scoped lang="less">
	.head_back {
		height: 160rpx;
		background: linear-gradient(63deg, #FF515E 0%, #FF7F3E 100%), linear-gradient(167deg, #FF6B4A 0%, rgba(255, 123, 77, 0) 100%);
	}

	.box {
		background: linear-gradient(92deg, #FEF3DE 0%, #F7E0BA 100%);
		border-radius: 20rpx 20rpx 0 0;
	}

	.title {
		color: #5B5C61;
	}
</style>